package lineSearch;

// make method static
public class LinearSearch_02 {
    public static int search(int[] data, int target) {
        for (int i = 0; i < data.length; i++) {
            if (data[i] == target) return i;
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] data = {24, 18, 12, 9, 16, 66, 32, 4};
//        lineSearch.LinearSearch_02 linearSearch = new lineSearch.LinearSearch_02();
        int result = LinearSearch_02.search(data, 16);
        System.out.println(result);
        // CTRL W select current word
        System.out.println(LinearSearch_02.search(data, 666));
    }
}
